<!--
 * @Description: 
 * @Version: 1.0
 * @Autor: younghxp
 * @Date: 2022-03-17 17:50:51
 * @LastEditors: younghxp
 * @LastEditTime: 2022-03-18 17:43:25
-->
<template>
  <div class="container">
    <div style="margin-bottom: 24px">
      <topTitle
        titleText="历史记录"
        :back="true"
        @gobackTriser="goBack"
      ></topTitle>
    </div>
    <operateListTab
      @getSelected="getCurrentTabComponent"
      :groupList="groupList"
    ></operateListTab>
    <component
      v-bind:is="currentTabComponent"
      :showHistory="false"
      :type="componentType"
      :projectId="projectId"
      :isSetting="isSetting"
      :isFB="isFB"
    ></component>
  </div>
</template>

<script>
import operateListTab from '@/components/publicCom/operateListTab'
import constructAttByDay from '@/components/constructAttendance/constructAttByDay'
import constructAttByMonth from '@/components/constructAttendance/constructAttByMonth'
import constructAttByYear from '@/components/constructAttendance/constructAttByYear'
import paymentRatio from '@/components/cashDeposit/paymentRatio'

export default {
  components: {
    operateListTab,
    constructAttByDay,
    constructAttByMonth,
    constructAttByYear,
    paymentRatio,
  },
  data() {
    return {
      currentTabComponent: 'constructAttByDay',
      componentType: '',
      groupList: [
        { name: '按日统计', componentName: 'constructAttByDay' },
        {
          name: '按月统计',
          componentName: 'constructAttByMonth',
          componentType: 'month',
        },
        {
          name: '按年统计',
          componentName: 'constructAttByYear',
          componentType: 'year',
        },
      ],
      projectId: '',
    }
  },
  created() {
    const { projectId, isSetting, isFB } = this.$route.query
    this.projectId = projectId
    this.isSetting = isSetting === 'true' ? true : false
    this.isFB = isFB === 'true' ? true : false
  },
  methods: {
    // 获取子组件上传成功后的值
    getCurrentTabComponent(data) {
      this.currentTabComponent = data.componentName
      this.componentType = data.componentType
    },
    goBack() {
      const { oldUrl, projectId, backPath } = this.$route.query
      this.$router.push({
        path: backPath,
        query: {
          projectId,
        },
      })
      this.$store.commit('GOBACK_NAME', {
        oldUrl,
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
  },
}
</script>

<style scoped lang="less">
.container {
  padding: 0;
}
</style>
